package com.jl.book.ui.home.adapter

import com.jl.book.bean.MyContacts
import java.util.*

/**
 * 首字母排序
 * 此类经供参考
 * @author jl
 */
class ComparatorLetter : Comparator<MyContacts?> {
    override fun compare(l: MyContacts?, r: MyContacts?): Int {
        if (l == null || r == null) {
            return 0
        }
        val lhsSortLetters = l.letter!!.substring(0, 1).toUpperCase(Locale.ROOT)
        val rhsSortLetters = r.letter!!.substring(0, 1).toUpperCase(Locale.ROOT)
        return lhsSortLetters.compareTo(rhsSortLetters)
    }
}